#!/usr/bin/env python

from distutils.core import setup
import subprocess
import os

# get revision number from repository

VERSION_FILE = "wltrcmd/__version__.py"


import wltrcmd

if wltrcmd.version:
    version = wltrcmd.version
else:

    info = subprocess.check_output(['svnversion', '--committed', '--no-newline',
                                    os.path.dirname(__file__)])
    try:
        rev = int(info.split(":",1)[1])
    except ValueError:
        raise RuntimeError("Can't cast revision number to int. Maybe the reporitory isn't comminted, yet.")
    
    version = '0.1.%d'%rev

    with open(VERSION_FILE, "w") as f:
        f.write("version = '%s'"%version)
    



setup(name='wltrcmd',
      version=version,
      description='',
      author='Sven Walter',
      author_email='sven.walter@z-worx.org',
      url='http://sven.wltr.eu/',
      packages=["wltrcmd"],
      scripts=['scripts/wltr-pypkg-install',
               'scripts/wltr-pypkg-build',
               'scripts/wltr-rename'],
      #install_requires=["Django>=1.2", "South>=0.7.3"],
     )

if not wltrcmd.version:
    os.remove(VERSION_FILE)